package top.gcl.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import top.gcl.interceptor.LoginInterceptor;

import javax.annotation.Resource;
//拦截器
@Configuration
public class SpringMVCConfig implements WebMvcConfigurer {
    //@Autowired 这两种注解那个都行 但是有区别 面试
    @Resource
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/login","/js/**","/css/**","/img/**");//排除这些东西  不拦截
    }
}
